<template>
  <div class="params">
    <el-row class="topw">
      <el-col :span="24">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>商品管理</el-breadcrumb-item>
          <el-breadcrumb-item>分类参数</el-breadcrumb-item>
        </el-breadcrumb>
      </el-col>
    </el-row>
    <el-row style="padding:10px 0">
      <el-col :span="24">
        <!-- 给组件绑定原生事件的话，需要一个.native的修饰符 -->
        <el-input placeholder="请输入内容" class="search-input"  @keydown.native.enter="initList">
          <el-button slot="append" icon="el-icon-search" @click="initList"></el-button>
        </el-input>
        <el-button type="success" plain @click="addDialogFormVisible=true">添加参数</el-button>
      </el-col>
    </el-row>
    <el-table class="margin-20" :data="paramsList" border style="width: 100%">
      <el-table-column type="index" width="50">
      </el-table-column>
      <el-table-column prop="attr_name" label="参数名称" width="180">
      </el-table-column>
      <el-table-column prop="cat_id" label="所属分类" width="180">
      </el-table-column>
      <el-table-column prop="attr_sel" label="only">
      </el-table-column>
      <el-table-column prop="attr_write" label="输入">
      </el-table-column>
      <el-table-column prop="attr_vals" label="vals">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" plain icon="el-icon-edit" @click="showEditDialog(scope.row)">
          </el-button>
          <el-button size="mini" type="danger" plain icon="el-icon-delete" @click="showDeleteDialog(scope.row)">
          </el-button>
          <el-button size="mini" type="warning" plain icon="el-icon-check" @click="showGrantDialog(scope.row)">
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import {
    addparams
  } from '@/api'
  export default {
    data() {
      return {
        paramsList: [],
        attr_id: 1,
        sel: 'only'
      }
    },
    created() {
      this.initList()
    },
    methods: {
      initList() {
        // this.loading = true  
        // console.log(id)
        addparams({
          params:{
            id: this.attr_id,
            sel: this.sel
          }
        }).then(res => {
          console.log(res)
          // console.log(params.id)
          // this.paramsList = res.data.users
          // this.total = res.data.total
          // this.loading = false
        })

      },
    }
  }

</script>
<style lang="scss" scoped>
  .params {
    .margin-20 {
      margin: 20px 0;
    }

    .search-input {
      width: 300px;
    }

    .page {
      padding: 5px 0;
      background-color: #D3DCE6;
    }
  }

</style>
